const path = require('path');

const Koa = require('koa');
const router = require('koa-router')();

const koaBody = require('koa-body');
const static = require("./static");
const templating = require('./templating');
const controller = require('./controller');

const app = new Koa();

app.use( static('/public/', __dirname + '/public') );

app.use(koaBody({
  multipart: true,
  formidable:{
    uploadDir: path.join(__dirname, 'public/upload/'),
    keepExtensions: true,
    multipart: false,
    maxFieldsSize: 2*1024*1024
  }
}));

app.use(templating());
app.use(controller());
app.use(router.routes());

app.listen(3000);

console.log('服务器正运行在 http://localhost:3000/');
